<?php 
class SurveyDemography
{
	public $Id;
	public $SurveyId;
	public $Active;
	public $Title;
	public $SubLoaded;
	public $DataChanged;
	public $Values;
	
	public function SurveyDemography() 
	{ 
		self::setSubLoaded(false);
		self::setDataChanged(false);
	}
	
	public function getId() { return $this->Id; }
	public function getSurveyId() { return $this->SurveyId; }
	public function getActive() { return $this->Active; }
	public function getTitle() { return $this->Title; }
	public function getSubLoaded() { return $this->SubLoaded; }
	public function getDataChanged() { return $this->DataChanged; }
	public function getValues() { return $this->Values; }
	
	public function setId($val) { $this->Id=$val; }
	public function setSurveyId($val) { $this->SurveyId=$val; }
	public function setActive($val) { $this->Active=$val; }
	public function setTitle($val) { $this->Title=$val; }
	public function setSubLoaded($val) { $this->SubLoaded=$val; }
	public function setDataChanged($val) { $this->DataChanged=$val; }
	public function setValues($val) { $this->Values=$val; }
	
	public function update()
	{
		if(($this->Id > 0) && ($this->DataChanged == true))
		{
			$sql  = 'UPDATE '.DB_PERFIX.'survey_demography SET ';
			$sql .= '`title`=\''.mysql_real_escape_string($this->Title).'\', ';
			$sql .= '`active`='.$this->Active.' ';
			$sql .= 'WHERE `id`='.$this->Id.';';
			$result = mysql_query($sql);
		}
	}
}

class DemographyValue
{
	public $Id;
	public $SurveyId;
	public $DemogId;
	public $Value;
	public $Active;
	public $DataChanged;
	
	public function SurveyDemography() 
	{ self::setDataChanged(false); }
	
	public function getId() { return $this->Id; }
	public function getSurveyId() { return $this->SurveyId; }
	public function getDemogId() { return $this->DemogId; }
	public function getValue() { return $this->Value; }
	public function getActive() { return $this->Active; }
	public function getDataChanged() { return $this->DataChanged; }
	
	public function setId($val) { $this->Id=$val; }
	public function setSurveyId($val) { $this->SurveyId=$val; }
	public function setDemogId($val) { $this->DemogId=$val; }
	public function setValue($val) { $this->Value=$val; }
	public function setActive($val) { $this->Active=$val; }
	public function setDataChanged($val) { $this->DataChanged=$val; }
	
	public function update()
	{
		if(($this->Id > 0) && ($this->DataChanged == true))
		{
			$sql  = 'UPDATE '.DB_PERFIX.'survey_demography_values SET ';
			$sql .= '`value`=\''.mysql_real_escape_string($this->Value).'\', ';
			$sql .= '`active`='.$this->Active.' ';
			$sql .= 'WHERE `id`='.$this->Id.';';
			$result = mysql_query($sql);
		}
	}
}
?>